home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Delphi Programmer's Power Pack
/
Delphi Volume 1.iso
/
e_to_l
/
isamexpt
/
wntisam1.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1996-09-15
|
14KB
|
485 lines
{HISTORY of Changes:
18.01.1996 Property NAME of ISAMBROWSER changed form ISAMBROWSER1 to RECORDNAME+BROWSER1
}
unit Wntisam1;
interface
Uses Classes, Forms, Graphics;
Function Erzeuge_BrowserForm(const FormIdent, TblName: string;
IniDatNam,IniBrwNam: String;
Fnt: TFont;
IIDList,KeyList,RecList: TStringList;
DBase_Export,DBase_Import: Boolean;
Sprache: Integer;
TblCreateBttn, SetupBttnCheck: Boolean): TForm;
implementation
Uses UToolDll, WinTypes, WinProcs, SysUtils,
ExtCtrls, Buttons, Controls, IsamTabl, IsamNav, IsamBrow,
Proxies, IStreams, FvcBrows;
Function Erzeuge_BrowserForm(const FormIdent, TblName: string;
IniDatNam,IniBrwNam: String;
Fnt: TFont;
IIDList,KeyList,RecList: TStringList;
DBase_Export,DBase_Import: Boolean;
Sprache: Integer;
TblCreateBttn, SetupBttnCheck: Boolean): TForm;
var
BtnPos : TPoint;
EdMethod,Method: TMethod;
MP,UP,Up1,Up2,Up3: TPanel;
SP : TSpeedButton;
Tbl : TIsamTable;
Tm : TTimer;
i,k : Integer;
ND : TIsamNavigator;
Grd : TIsamBrowser;
Hdr : THeader;
x : Integer;
RStr,NStr,xStr,RNam : String;
Liste1,Liste2,Liste3: TStringList;
begin
Result := TProxyForm.CreateAs('T' + FormIdent);
with Result do begin
BorderStyle := bsDialog;
AutoScroll := True;
Left := 92;
Top := 97;
Width := 562;
Height:= 352;
Position := poScreenCenter;
Name := FormIdent;
Caption := 'Browser';
Method.Code := TProxyForm(Result).CreateMethod('FormCreate');
Method.Data := Result;
OnCreate := TNotifyEvent(Method);
Method.Code := TProxyForm(Result).CreateMethod('FormDestroy');
Method.Data := Result;
OnDestroy := TNotifyEvent(Method);
Method.Code := TProxyForm(Result).CreateMethod('FormShow');
Method.Data := Result;
OnShow := TNotifyEvent(Method);
with Font do begin
Color := clBlack;
Height:= -11;
Name := 'Arial';
Size := 8;
Style:= [fsBold];
end;
MP:= TPanel.Create(Result);
with MP do begin
Parent := Result;
Name := 'Panel1';
Left := 0;
Top := 0;
Width := 554;
Height := 41;
Align := alTop;
ParentShowHint:= False;
ShowHint := True;
TabOrder := 1;
Caption:= '';
end;
Tm:= TTimer.Create(Result);
With Tm do begin
Interval:= 1000;
Name:= FormIdent+'Timer';
Method.Code := TProxyForm(Result).CreateMethod(FormIdent+'TimerTimer');
Method.Data := Result;
Tm.OnTimer := TNotifyEvent(Method);
end;
Hdr:= THeader.Create(Result);
with Hdr do begin
Parent:= Result;
Name:= 'HEADER1';
Left:= 0;
Top:= 41;
Height:= 25;
Width:= 554;
Method.Code := TProxyForm(Result).CreateMethod('Header1Sized');
Method.Data := Result;
OnSized:= TSectionEvent(Method);
end;
Tbl:= TIsamTable.Create(Result);
with Tbl do begin
Name:= FormIdent+'TABLE';
TableName:= TblName;
BrowserName:= 'IsamBrowser1';
HeaderName:= 'HEADER1';
Ansiconvert:= True;
Liste1:= TStringList.Create;
{IIDProc.Clear;}
x:= 0;
While x < IIDList.Count do begin
Liste1.Add(IIDList[x]);
Inc(x);
end;
MaxKeys:= x;
IIDProc:= Liste1;
Liste1.Free;
Liste2:= TStringList.Create;
{IsamRecord.Clear;}
RecordName:= '';
x:= 0;
While x < RecList.Count do begin
Liste2.Add(RecList[x]);
RStr:= Uppercase(RecList[x]);
Strip(RStr);
if Pos('=RECORD',RStr) > 0 then RecordName:= Copy(RStr,1,Pos('=RECORD',RStr)-1);
inc(x);
end;
RNam:= RecordName;
IsamRecord:= Liste2;
Liste2.Free;
{IsamKeyProc.Clear;}
Liste3:= TStringList.Create;
K:= 0;
if KeyList.Count > 0 then begin
Liste3.Add('Function '+RNam+'KeyProc(Var Daten; KeyNr:Word): IsamKeyStr;');
Liste3.Add('var s : String;');
Liste3.Add('begin');
Liste3.Add(' s:= '+Chr(39)+Chr(39)+';');
Liste3.Add(' With '+RNam+'(Daten) do begin');
Liste3.Add(' case KeyNr of');
For x:= 0 to KeyList.Count-1 do begin
NStr:= KeyList[x];
NStr:= UpperCase(NStr);
if Pos(';',NStr) = 0 then KeyList[x]:= KeyList[x]+';';
Strip(NStr);
if (Pos('KEYBEGIN',NStr) = 0) and (Pos('KEYEND',NStr) = 0) then begin
inc(K);
Str(k,xStr);
Liste3.Add(xStr+': '+KeyList[x]);
end;
end;
Liste3.Add(' end;');
Liste3.Add(' end;');
Liste3.Add(' '+RNam+'KEYPROC:= S;');
Liste3.Add('end;');
end;
IsamKeyProc:= Liste3;
Liste3.Free;
MyUnitName:= FormIdent;
end;
Grd:= TIsamBrowser.Create(Result);
with Grd do begin
Parent := Result;
Name := RNam+'Browser1';
Left := 0;
Top := 66;
Width := 554;
Height := 232;
Align := alNone;
JustRightChar := '░';
JustLeftChar := '|';
JustCenterChar := '~';
Color := clSilver;
BrowserHeader := Hdr;
Table := Tbl;
Font.Color := Fnt.Color;
Font.Height := Fnt.Height;
Font.Name := Fnt.Name;
Font.Style := Fnt.Style;
ParentFont := False;
TabOrder := 2;
EdMethod.Code := TProxyForm(Result).CreateMethod('EditBttnClick');
EdMethod.Data := Result;
Grd.OnDblClick := TNotifyEvent(EdMethod);
Method.Code:= TProxyForm(Result).CreateMethod(RNam+'Browser1BuildRow');
Method.Data:= Result;
Grd.OnBuildRow:= TBuildRowEvent(Method);
end;
ND:= TIsamNavigator.Create(Result);
with ND do begin
Parent:= MP;
Browser:= Grd;
Name:= 'IsamNavigator1';
ConfirmDelete:= False;
Left:= 8;
Top:= 8;
VisibleButtons:= [nbFirst,nbPrior,nbNext,nbLast];
Width:= 100;
end;
Sp:= TSpeedButton.Create(Result);
with SP do begin
Parent:= MP;
Left:= 128;
Top := 8;
Width := 25;
Height := 25;
if Sprache = 1 then Hint:= 'New record'
else Hint := 'Neuer Datensatz';
Name := 'NeuBttn';
Glyph.Handle:= LoadBitmap(HInstance,'IS_NEU');
Method.Code := TProxyForm(Result).CreateMethod('NeuBttnClick');
Method.Data := Result;
Sp.OnClick := TNotifyEvent(Method);
end;
Sp:= TSpeedButton.Create(Result);
with SP do begin
Parent:= MP;
Left:= 156;
Top := 8;
Width := 25;
Height := 25;
if Sprache = 1 then Hint:= 'Edit record'
else Hint := 'Datensatz bearbeiten';
Name := 'EditBttn';
Glyph.Handle:= LoadBitmap(HInstance,'IS_AENDERN');
Sp.OnClick := TNotifyEvent(EdMethod);
end;
Sp:= TSpeedButton.Create(Result);
with SP do begin
Parent:= MP;
Left:= 184;
Top := 8;
Width := 25;
Height := 25;
if Sprache = 1 then Hint:= 'Search'
else Hint := 'Suchen';
Name := 'SuchBttn';
Glyph.Handle:= LoadBitmap(HInstance,'IS_SUCH');
Method.Code := TProxyForm(Result).CreateMethod('SuchBttnClick');
Method.Data := Result;
Sp.OnClick := TNotifyEvent(Method);
end;
Sp:= TSpeedButton.Create(Result);
with SP do begin
Parent:= MP;
Left:= 212;
Top := 8;
Width := 25;
Height := 25;
if Sprache = 1